package com.hqyj.springtest.controller;

import java.lang.ProcessBuilder.Redirect;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hqyj.springtest.pojo.School;
import com.hqyj.springtest.service.SchoolService;
@Controller
@CrossOrigin
public class SchoolController {
@Autowired
SchoolService ss;
@RequestMapping("query.do")
@ResponseBody
public List<School> query3(){
	List<School> list=ss.getAllSchool();
	return list;
}
@RequestMapping("add.do")
@ResponseBody
public Map<String, Boolean> add(School school){
	int sch=ss.addScholl(school);
	System.out.println("---------"+sch);
	Map<String, Boolean> map=new HashMap<String,Boolean>();
	if(sch==1) {
		System.out.println("---------------");
		map.put("msg", true);
	}else {
		map.put("msg", false);
	}
	return map;
}
@RequestMapping("update.do")
@ResponseBody
public Map<String, Boolean> update(School school){
	System.out.println("---------------1111111111");
		int sch=ss.updateSchool(school);
		System.out.println("---------------");
		Map<String, Boolean> map=new HashMap<String,Boolean>();
		if(sch==1) {
			map.put("msg", true);
		}else {
			map.put("msg", false);
		}
	return map;
}
@RequestMapping("del.do")
@ResponseBody
public void del(String sid) {
	System.out.println("------");
	int sid1=Integer.parseInt(sid);
	ss.delSchool(sid1);
	
}

}

